﻿<?php
    //error_reporting(0);
    session_start();
	$CName = $_POST["CName"];
	$password = $_POST["password"];
	include("../class/company.class.php");
	$Company = new Company();
	if(!$_POST[CName])
	{
		echo '<script>alert("请输入账户名!");window.location.href="../pages/login.php";</script>';
	}
	if(!$_POST[password])
	{
		echo '<script>alert("请输入密码!");window.location.href="../pages/login.php";</script>';
	}
	$id_company = $Company->login($CName,$password);//公司登陆，返回公司id
	if($id_company > 0)
	{
		$_SESSION["Company_Id"] = $id_company;
		echo '<script>window.location.href="../company/index.php";</script>';
		exit();
	}
	else
	{
		//登陆失败
		echo '<script>alert("账户名或者密码错误!");window.location.href="../pages/login.php";</script>';
		exit();
	}
?>